#!/usr/bin/python
# -*-coding: UTF-8 -*-
"""
# Time: 2024/5/11 20:35
# @Author: 修养
# @Project_name: PROJECT_NAME
"""


# def do():
#     print("好好学习，天天向上")
#
#
# def hobby(name, hobbies):
#     print(name + "喜欢" + hobbies)
#
#
# def shops(fruit, much="10美元"):
#     print(fruit + "售价：" + much)


# 函数调用
# do()  # 无参
# hobby("毛泽东", "看书")  # 给形参传实参，且是位置实参
# hobby(name="周恩来", hobbies="读书")  # 关键字实参
# shops("苹果")  # much="10美元" 形参给个默认值，不传这个实参
# shops("香蕉", "2美元")  # 位置形参，参数顺序不能错误
# shops("葡萄", much="6美元")  # 用了关键字实参，后续只能用关键字实参
# shops(fruit="猕猴桃", much="3美元")  # 用了关键字实参，后续只能用关键字实参

def do():
    print("好好学习, 天天向上")


def hobby(name, hobbys):
    print(f"{name}喜欢{hobbys}")


def shops(fruit, much='1元'):
    print(f"{fruit}，售价：{much}")


# 调用函数
do()
hobby("周恩来", "读书")
hobby(name="毛泽东", hobbys="读书")
hobby("李大钊", hobbys="读书")
shops("苹果")
shops("苹果", "3元")
shops(fruit="香蕉", much="4元")
print("~~~~~~~~~~~~~~有返回值的函数~~~~~~~~~~~~")


# def sum(a, b):
#     sums = a + b
#     return sums
#
#
# def students(classes, grade=None):
#     """
#     定义一个字典，并增加键值对
#     """
#     student = {'id': '0001', 'name': '毛泽东'}
#     if classes:
#         student['classes'] = classes
#         student['grade'] = grade
#     return student
#
#
# c = sum(2, 5)
# print(c)
# students = students("五一班", 98)
# print(students)
def sum(a, b):
    c = a + b
    return c


def classes(name, grade=None):
    """
    定义一个键值对
    """
    students = {"classes": "八一班", "name": "周恩来", "grade": 100}
    if name:
        students["name"] = name
        students["grade"] = grade
    return students


# 调用函数
c = sum(1, 3)
print("c =", c)
stu = classes("毛泽东", 99)
print("输出stu:", stu)